﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Office.Interop.Word;

namespace AutoHistory2010ForWord
{
    internal class WordComparer
    {
        private Application word;

        public WordComparer(Application wordApplication)
        {
            this.word = wordApplication;
        }

        public void Compare(string sourceDocFile, string historyDocFile)
        {
            object missing = Type.Missing;
            object f = false;
            object t = true;
            object es = String.Empty;
            object frm = Microsoft.Office.Interop.Word.WdOpenFormat.wdOpenFormatAuto;
            object me = Microsoft.Office.Core.MsoEncoding.msoEncodingAutoDetect;
            object wd = Microsoft.Office.Interop.Word.WdDocumentDirection.wdLeftToRight;
            object format = WdOriginalFormat.wdWordDocument;
            object file = historyDocFile;
            Document histDoc = this.word.Documents.Open(ref file, ref t, ref t, ref f, ref missing, ref missing, ref missing, ref missing, ref missing, ref frm, ref me, ref t, ref f, ref wd, ref t, ref missing);

            object target = WdCompareTarget.wdCompareTargetNew;
            object author = "Comparison";

            histDoc.Compare(sourceDocFile, ref author, ref target, ref t, ref t, ref f, ref t, ref t);

            histDoc.Close(ref f, ref format, ref f);

            object cnt = 1;
            this.word.Windows.get_Item(ref cnt).Activate();
        }
    }
}
